

#ifndef __ADC_BSP_H_
#define __ADC_BSP_H_

#ifdef ADC_VAR
#define ADC_EXT
#else
#define ADC_EXT extern
#endif

#include "stdio.h"
#include "include.h"
#include "cs32f10x_adc.h"
#include "cs32f10x_usart.h"
#include "cs32f10x_gpio.h"
#include "cs32f10x_rcu.h"


#define RC		100000.0f
#define constA	0.000564606f
#define constB	0.000241961f



#define AdRefValue	3300 //mv		
#define AdValueMax	4095 //12bit 		
#define Mv_1AD			0.80586//mv 3300/4095	

#define ADMAX 0
#define ADMIN 0xfff

#define FirPowDetDelayT	800
ADC_EXT uint16_t FirPowDetDelay;

ADC_EXT uint8_t  Adchannel;
ADC_EXT uint16_t AdcValue[8];
ADC_EXT uint16_t adc_input_value;

ADC_EXT float		PA0_Voltage_Compensate;
ADC_EXT float		PA0_Voltage;	
ADC_EXT uint16_t PA0_Adc_Value;
ADC_EXT uint16_t AdSum;
ADC_EXT uint16_t AdSampleCnt;

ADC_EXT float		PA1_Voltage;	
ADC_EXT uint16_t PA1_Adc_Value;
ADC_EXT uint16_t AdSum1;
ADC_EXT uint16_t AdSampleCnt1;

ADC_EXT float		PA2_Voltage;	
ADC_EXT uint16_t PA2_Adc_Value;
ADC_EXT uint32_t AdSum2;
ADC_EXT uint16_t AdSampleCnt2;

ADC_EXT float		PA3_Voltage;	
ADC_EXT uint16_t PA3_Adc_Value;
ADC_EXT uint32_t AdSum3;
ADC_EXT uint16_t AdSampleCnt3;

ADC_EXT int8_t  NTC1_temp;
ADC_EXT int8_t  NTC2_temp;
ADC_EXT int8_t  NTC3_temp;
ADC_EXT int8_t  NTC4_temp;



ADC_EXT uint8_t  ConnectGndOkCnt,ConnectGndOkCnt1,ConnectGndOkCnt2;


void NTC_adc_init(void);
uint16_t adc_sample_value(void);

void GetAdcValue(void);
int8_t  value_to_temp(uint16_t adcsum);

#endif

